package homework.api.day06._cp;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class StringDemo {
    public static void main(String[] args) throws IOException {
        String line = "渭城朝雨浥轻尘，客舍青青柳色新。";

        FileOutputStream fos = new FileOutputStream("hfos.txt",true);
        fos.write(line.getBytes(StandardCharsets.UTF_8));
        System.out.println("书写完成");
        fos.close();

        File file = new File("hfos.txt");
        FileInputStream fis = new FileInputStream(file);
        byte[] data = new byte[(int)file.length()];
        fis.read(data);
        String str = new String(data,StandardCharsets.UTF_8);
        System.out.println(str);
        fis.close();
    }
}
